package cc.lj.internal.coupons.domain.ticket.service.impl;


import cc.lj.internal.coupons.domain.martcap.model.vo.BatchBindRelationDO;
import cc.lj.internal.coupons.domain.martcap.model.vo.convert.BatchBindRelationPOConvertDO;
import cc.lj.internal.coupons.domain.ticket.model.vo.convert.TicketBatchPOConvertDO;
import cc.lj.internal.coupons.domain.ticket.repository.IBatchBindRelationRepository;
import cc.lj.internal.coupons.domain.ticket.service.IBatchBindRelationDomainService;
import cc.lj.internal.coupons.infrastructure.po.BatchBindRelationPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 电子券批次绑定关系表领域服务service实现类
 * @author liangxifeng
 * @date 2022-06-12
 */
@Service("batchBindRelationDomainServiceImpl")
@Slf4j
public class BatchBindRelationDomainServiceImpl implements IBatchBindRelationDomainService {
    //电子券批次绑定关系表仓储接口
    @Resource(name = "batchBindRelationRepository")
    private IBatchBindRelationRepository repository;


    /**
     * 通过主键查询一条记录
     * @param id
     * @return
     */
    public BatchBindRelationDO getById(Integer id)
    {
        BatchBindRelationPO batchBindRelationPO = repository.getById(id);
        return BatchBindRelationPOConvertDO.INSTANCE.convert(batchBindRelationPO);
    }


    /**
     * 标准批量获取数据的方法
     * @param batchBindRelationDO
     * @return
     */
    public List<BatchBindRelationDO> getList(BatchBindRelationDO batchBindRelationDO)
    {
        BatchBindRelationPO batchBindRelationPO = BatchBindRelationPOConvertDO.INSTANCE.convert(batchBindRelationDO);
        List<BatchBindRelationPO> list = repository.getList(batchBindRelationPO);
        List<BatchBindRelationDO> newList = new ArrayList<>();
        for(BatchBindRelationPO item : list)
        {
            newList.add(BatchBindRelationPOConvertDO.INSTANCE.convert(item));
        }
        return newList;
    }

}
